package net.fdukedom.epicurus.client.connection;

import net.fdukedom.epicurus.client.stub.EpicurusWSInterfacePort;
import net.fdukedom.epicurus.client.util.ConfigurationHelper;

public class ServiceWrapper {
    /**
     * Web service server URL
     */
    private String serverURL;

    /**
     * Constructor
     */
    ServiceWrapper() {
        init();
    }

    /**
     * Sets web service server URL
     * 
     * @param
     */
    public void setServerURL(String serverURL) {
        this.serverURL = serverURL;
    }

    /**
     * Returns web service server URL
     * 
     * @return web service server URL
     */
    public String getServerURL() {
        return serverURL;
    }

    /**
     * Creates web service client port
     * 
     * @return web service client port
     */
    protected EpicurusWSInterfacePort createPort() {
        ServicePortFactory portFactory = new OpenPortFactory();
        return portFactory.createPort(serverURL);
    }

    /**
     * Initialize wrapper configuration
     * 
     * @param configFileName
     *            configuration xml file
     * @return true if configuraion was loaded succesfully
     */
    protected void init() {
        ConfigurationHelper config = new ConfigurationHelper();
        
        setServerURL(config.getServerURL());
    }
}
